<template>
  <div>
    <transition name="fade">
      <router-view></router-view>
    </transition>
    <audio id="audio" src="/static/prompt/prompt.mp3"></audio>
  </div>
</template>

<script>
  import {fetchList} from '@/api/order/order'

  export default {
    data() {
      return {
        shopId: this.$store.state.user.shopId
      }
    },
    mounted() {
      // this.getList()
      this.timer = setInterval(this.getList, 10000);
    },
    methods: {
      //获取数据列表
      getList() {
        let data = new FormData()
        data.append('shopId', this.shopId)
        data.append('orderStatus', 1)
        data.append('payStatus', 1)
        data.append('serviceStatus', 1)
        data.append('commentStatus', 1)
        fetchList(data).then(response => {
          if (response.data.code === 0 && response.data.data.list.length > 0) {
            this.aplayAudio()
          }
        })
      },
      aplayAudio() {
        const audio = document.getElementById('audio')
        audio.play()
      }
    },
    beforeDestroy() {
      clearInterval(this.timer);
    }
  }
</script>
